import React from "react";
import { connect } from "react-redux";
// 如何让你子组件在不在redux的情况下操作仓库
import { bindActionCreators } from "redux";
import { pushAction } from "./store/actionCreators";
import Child from "./child";
const Home = props => {
  // console.log(props);
  // 1.参数：动作对象，2.参数：dispatch
  // bindActionCreators:第一个参数，如果咱传入的是一个对象，则表示
  const pushitem = bindActionCreators(pushAction, props.dispatch);
  // pushitem = value => props.dispatch(pushAction(value))
  return (
    <div>
      <Child pushitem={pushitem} />
      {props.list.map(item => {
        return <p key={item.id}>{item.label}</p>;
      })}
    </div>
  );
};
// 1.获取值得参数
const mapStateToProps = state => state;
export default connect(mapStateToProps)(Home);
